<%-- 
    Document   : hipoteca
    Created on : 11-jun-2009, 13:44:52
    Author     : Ale
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" session="false" import="domain.*, planner.*, java.util.Iterator, java.util.Set, java.util.List, java.sql.Date"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>DOMECO</title>
        <link href="style.css" rel="stylesheet" type="text/css">
    </head>
    <body>

        <%if (request.getSession(false) != null) {%>
        <table align="center" width="1000" border="0">
            <tr>
                <td>
                    <div id="menu" align="center"><jsp:include page="./menu principal.jsp"></jsp:include></div>
                    <br>
                    <p id="campoAzul" align="center" valign="middle" width="235px"><span id="blanco">Hipotecas</span><br></p>
                    <span id="azulTitulo"> Hipotecas y mensualidades añadidas</span>
                    <div id="general">
                        <div id="cuenta" align="center" >
                            <%
    Userdom user = (Userdom) request.getSession().getAttribute("user");
    Operations o = new Operations();
    List l = o.getMortgageContrList(user);
    double amount = 0.0;
    boolean ocultar = false;
    if (l.isEmpty()) {
        ocultar = true;
                            %>
                            <br>
                            <br>
                            <p align=right"><span id="rojo"> Noy hay Contratos de Hipoteca</span></p>
                            <%                            } else {
                                Iterator it1 = l.iterator();
                                while (it1.hasNext()) {
                                    Mortgagecontract e = (Mortgagecontract) it1.next();


                                    java.sql.Date dateExpired = e.getDateOfExpiration();
                            %>
                            <p align=right"><span id="datosCuenta">Contrato: <%=e.getContract().getNameContract()%>, Intereses: <%=e.getInterest()%> €, Total a pagar: <%=e.getTotal()%> €</span></p>
                            <%
                            List lh = o.getMortgageContrList(user);
                                Iterator it1h = lh.iterator();
                                while (it1h.hasNext()) {
                                    Mortgagecontract ec = (Mortgagecontract) it1h.next();

                                    Mortgageconsumption mCons = new Operations().getLastMortgConsumption(ec);
                                    if (mCons != null) {
                                        %>
                            <table id="tabla">
                                <tr id="campoAzul" align="center">
                                    <td width="200px"><span id="blanco">Periodo facturado</span></td>
                                    <td width="200px"><span id="blanco">Fecha fin de Hipoteca</span></td>
                                    <td><span id="blanco" >Letra( en €)</span></td>
                                </tr>
                                <%
                                amount = mCons.getConsumption().getAmount();
                                java.sql.Date from = mCons.getDateFrom();
                                java.sql.Date to = mCons.getDateTo();
                                %>
                                <tr id="datosCuenta" align="center">
                                    <td><span><%=from%> --- <%=to%></span></td>
                                    <td><span><%=dateExpired%></span></td>
                                    <td><span><%=amount%> €</span></td>
                            </tr></table>
                            <br>
                            
                            <%
                            } else {
                            %> <p align=center"><span id="rojo"> Noy hay Cuotas para esta Hipoteca</span></p> <%
                            }

        }
    }
                                }
                            %>


                        </div>


                        <div id="barraDer">

                            <div id="accesos">
                                <table align="center">
                                    <tr ><td bgcolor="#79A9D9" align="center" valign="middle" width="235px"><span id="blanco">Accesos frecuentes</span><br></td></tr>
                                </table>

                                <p align="center"><a href="./FrontController?redir=NCH" id="colorEvento"><span onmouseover='this.style.color="#FF9900"' onmouseout='this.style.color="#79A9D9"'>A&ntilde;adir Contrato hipoteca</span></a></p>
      <%if(!ocultar){ %>           <p align="center"><a href="./FrontController?redir=NFH" id="colorEvento"><span onmouseover='this.style.color="#FF9900"' onmouseout='this.style.color="#79A9D9"'>A&ntilde;adir Cuota hipoteca</span></a></p><%}%>
      <%if(!ocultar){ %>          <p align="center">  <a href="./FrontController?redir=MBCH" id="colorEvento"><span onmouseover='this.style.color="#FF9900"' onmouseout='this.style.color="#79A9D9"'>Modificar/Borrar contrato</span></a></p><%}%>
                                <p align="center">  <a href="./FrontController?redir=CH" id="colorEvento"><span onmouseover='this.style.color="#FF9900"' onmouseout='this.style.color="#79A9D9"'>Calcular hipoteca</span></a></p>

                            </div>

                            <div id="estadisticas">
                                <table align="center">
                                    <tr ><td bgcolor="#79A9D9" align="center" valign="middle" width="235px"><span id="blanco">Datos actuales</span><br></td></tr>
                                </table>

                                <p align="center">  <span id="colorEvento">Consumo última factura:<span id="rojo"><%=amount%>€</span></span></p>
                            </div>
                        </div>
                    </div>

<div id="abajo" align="center"><p>&copy;   Domeco &mdash; Proyecto Informático A&ntilde;o 2009 </p></div>
                </td>
            </tr>
        </table>
        <%} else {%>
        <jsp:forward page="./index.jsp"></jsp:forward>
        <%}%>
    </body>
</html>